package com.example.myapplication.module1.presenter

import com.example.myapplication.MyApplication
import com.example.myapplication.module1.activity.PersonalScheduleActivity
import com.example.myapplication.soaprequest.CustomerObserverSoap
import com.example.myapplication.soaprequest.SoapEnvelop
import com.example.mylibrary.base.BasePresenterImpl
import com.example.mylibrary.network.RetrofitUtil
import io.reactivex.disposables.Disposable

class PersonalSchedulePresenter : BasePresenterImpl<PersonalScheduleActivity>() {
    fun getSchedule(soapEnvelop: SoapEnvelop) {
        RetrofitUtil.initObservableCall(
            MyApplication.createService.soapRequest(soapEnvelop),
            object : CustomerObserverSoap {

                override fun onSubscribe(d: Disposable) {
                    mView?.showLoad()
                }

                override fun onComplete() {
                    mView?.dismissLoad()
                }

                override fun onSuccess(result: String) {
                    mView?.setScheduleResult(result)
                }
            })
    }

    fun delSchedule(soapEnvelop: SoapEnvelop) {
        RetrofitUtil.initObservableCall(
            MyApplication.createService.soapRequest(soapEnvelop),
            object : CustomerObserverSoap {

                override fun onSubscribe(d: Disposable) {
                    mView?.showLoad()
                }

                override fun onComplete() {
                    mView?.dismissLoad()
                }

                override fun onSuccess(result: String) {
                    mView?.delScheduleResult(result)
                }
            })
    }
}
